﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.EmployeeOvertime"
           xmlns:vc="clr-namespace:LEEAAttendanceControl.Codes"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Employee Overtime">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <LinearGradientBrush x:Key="BackRectangleBrush" EndPoint=".7,1" StartPoint=".7,0">
                <GradientStop Color="#FCFFFFFF" Offset="0.015"/>
                <GradientStop Color="#F7FFFFFF" Offset="0.375"/>
                <GradientStop Color="#E5FFFFFF" Offset="0.6"/>
                <GradientStop Color="#D1FFFFFF" Offset="1"/>
            </LinearGradientBrush>

            <vc:MinutesToHoursConverter x:Key="MinutesToHoursConverter"/>
        </Grid.Resources>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="280"/>
            <RowDefinition Height="280"/>
        </Grid.RowDefinitions>

        <StackPanel Orientation="Vertical" Grid.Row="0">
            <Grid Background="#404041" HorizontalAlignment="Stretch">
                <TextBlock Text="Employee Hours" Foreground="White" FontSize="14" FontWeight="Bold" Margin="5,3,3,3"/>
            </Grid>

            <riaControls:DomainDataSource x:Name="HoursSummaryDataSource" AutoLoad="True" QueryName="GetHoursSummaries"
                                          LoadingData="HoursSummaryDataSource_LoadingData">
                <riaControls:DomainDataSource.DomainContext>
                    <my:LEEAContext />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>

            <sdk:DataGrid x:Name="EmployeesGrid" IsReadOnly="True" AutoGenerateColumns="False"
                          ItemsSource="{Binding Data, ElementName=HoursSummaryDataSource}" MaxHeight="250"
                          VerticalScrollBarVisibility="Visible" SelectionChanged="EmployeesGrid_SelectionChanged">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTemplateColumn Header="Employee Name britch" CanUserReorder="False" CanUserResize="True"
                                                    Width="180" IsReadOnly="True">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                    <TextBlock Text="{Binding FirstName}"/>
                                    <TextBlock Text=" "/>
                                    <TextBlock Text="{Binding LastName}"/>
                                </StackPanel>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>

                    <sdk:DataGridTemplateColumn Header="Total" CanUserSort="True" Width="80">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Total, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Breaks" CanUserSort="True" Width="70">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Breaks, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Exceptions" CanUserSort="True" Width="75">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Exceptions, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Paid" CanUserSort="True" Width="80">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Paid, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Overtime" CanUserSort="True" Width="70">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding Overtime, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
        </StackPanel>

        <StackPanel Orientation="Vertical" Grid.Row="1">
            <Grid Background="#404041" HorizontalAlignment="Stretch">
                <TextBlock Text="Overtime Approval" Foreground="White" FontSize="13" FontWeight="Bold" Margin="5,2,2,2"/>
            </Grid>

            <sdk:DataGrid x:Name="OvertimeGrid" IsReadOnly="True" AutoGenerateColumns="False" MaxHeight="255"
                          VerticalScrollBarVisibility="Visible">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTemplateColumn Header="Day" CanUserSort="True" Width="190">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding ActualIN, StringFormat='dd/MM/yyy'}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Paid Hours" CanUserSort="True" Width="183">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding ActualHours, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Actual Overtime" CanUserSort="True" Width="200">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding ActualOvertime, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTemplateColumn Header="Rounded Overtime" Width="203" CanUserSort="False">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <sdk:Label Content="{Binding RoundedOvertime, Converter={StaticResource MinutesToHoursConverter}}"
                                           Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                           Height="25"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
        </StackPanel>
    </Grid>
</navigation:Page>
